package entities.concept;

import entities.vocabulary.Display;
import entities.vocabulary.KBVocabulary;

/**
 * Primitive/Atomic/Named Concepts
 * @author j55wu
 *
 */
public class PConcept extends Concept {
	private final String name;
	private static int freshcounter = 0;
	private static final String freshname = "fresh_name_";
	
	public PConcept(String name){
		this.name = name;
	}
	
	public static PConcept newFreshPConcept(){
		return new PConcept(PConcept.freshname + PConcept.freshcounter++);
	}
	
	public int numberOfFreshPConceptCreated(){
		return freshcounter;
	}
	
	public boolean isTop(){
		return this.name.compareToIgnoreCase(KBVocabulary.TOP)==0;
	}
	
	public boolean isBottom(){
		return this.name.compareToIgnoreCase(KBVocabulary.BOTTOM) == 0;
	}
	
	public String getPCName(){
		return this.name;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (! (obj instanceof PConcept))
			return false;
		if (getClass() != obj.getClass())
			return false;
		PConcept other = (PConcept) obj;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		return true;
	}
	
	@Override
	public String toString() {
		if(this.isTop()){
			return Display.TOPUNICODE;
		}else if(this.isBot()){
			return Display.BOTTOMUNICODE;
		}else{
			return name;
		}
	}

	@Override
	public Concept getPrimeCopy() {
		return new PConcept(this.name + Concept.PRIME);
	}
	
	
}
